#include "sha.h"
#include <sstream>
#include <iomanip>

size_t SHA::_fnv1aHash(const std::string& str) {
    const size_t prime = 0x100000001b3;
    size_t hash = 0xcbf29ce484222325;
    
    for (char c : str) {
        hash ^= c;
        hash *= prime;
    }
    return hash;
}
/**
 * 双哈希key 生成
 */
std::string SHA::hash(const std::string& str) {
    size_t h1 = std::hash<std::string>{}(str);
    size_t h2 = SHA::_fnv1aHash(str);
    return std::to_string(h1) + "_" + std::to_string(h2);
}


